var vueApp = new Vue({
  el: '#app',
  data: function () {
    return { 
    	colnum:2,
        datalist: [],
        collist: [],  
        arr: [],        
      };
  },

  mounted: function () {
	 var obj={};
	 obj= {"tb":[{"info":"客户端","collist":[{"colname":"A"},{"colname":"B"}],"rowlist":[{"places":"汉文报融媒体中心-新闻编辑部","lines":[{"name":"A","datas":[{"name":"张三1"},{"name":"张三2"}]},{"name":"B","datas":[{"name":"王五1"},{"name":"王五2"},{"name":"王五3"},{"name":"王五4"},{"name":"王五5"}]}]},{"places":"部门二","lines":[{"name":"A","datas":[{"name":"赵六1"},{"name":"赵六2"}]},{"name":"B","datas":[{"name":"王八1"},{"name":"王八2"}]}]}]},{"info":"报端","collist":[{"colname":"A"},{"colname":"B"}],"rowlist":[{"places":"部门一","lines":[{"name":"A","datas":[{"name":"李四1"},{"name":"李四2"}]},{"name":"B","datas":[{"name":"张三1"}]}]},{"places":"部门二","lines":[{"name":"A","datas":[]},{"name":"B","datas":[{"name":"刘九1"},{"name":"刘九2"}]}]}]}]};
	 obj= {"name":"金山岭-蟠龙山长城","fb_date":"2020-11-29","tb":[{"info":"车辆一 ","collist":[{"colname":"网名"}],"rowlist":[{"places":"5:00 北辰双街对面(柴楼)","lines":[{"name":"A","datas":[{"name":"快乐生活"}]}]},{"places":"5:05 北辰中医对面(天桥下)","lines":[{"name":"A","datas":[{"name":"缥缈"},{"name":"静心-一墨挂"}]}]},{"places":"5:20 西沽公园 对面(天桥下)","lines":[{"name":"A","datas":[{"name":"雨天"},{"name":"十月"},{"name":"龙哥"},{"name":"大元帅"}]}]},{"places":"5:30 南京路血液病医院对面公交站","lines":[{"name":"A","datas":[{"name":"空谷幽兰"},{"name":"大山"},{"name":"玉国"},{"name":"李卫"},{"name":"阿丽"},{"name":"小田田"},{"name":"海河，"},{"name":"再不斩"},{"name":"lina"},{"name":"頑奇蕫蕫-董"},{"name":"老李"}]}]},{"places":"5:45 土城地铁站D口","lines":[{"name":"A","datas":[{"name":"anmm"},{"name":"周鹏"},{"name":"山谷"},{"name":"诚信一族"},{"name":"没有土地的农民"},{"name":"冯刚"},{"name":"金麒麟"},{"name":"蜘蛛"},{"name":"生活"}]}]},{"places":"5:50 中山门二号路公交站","lines":[{"name":"A","datas":[{"name":"方如刚"},{"name":"树姐"},{"name":"叶子"},{"name":"清欢"},{"name":"清欢挂-阿良"},{"name":"脑袋嗷嗷大"},{"name":"祥漋慕"},{"name":"一路有你"},{"name":"秋风-一路有你挂"},{"name":"米蘭"}]}]},{"places":"6:00 靖江路地铁路C口对面","lines":[{"name":"A","datas":[{"name":"奶油"},{"name":"惜缘"},{"name":"潇莹"},{"name":"白雪"},{"name":"天石"},{"name":"珠珠-塘沽"},{"name":"老栾-要运动了"},{"name":"百瑞达超市晨曦店"},{"name":"林中水滴"}]}]}]}],"respCode":"0","respDesc":"OK"};

	 this.datalist=obj.tb;
	 this.collist=this.datalist[0].collist;
	 //this.arr= this.filltoArr(this.datalist[0].rowlist[0].lines); 
	 //console.log(this.getMax(this.arr));      
	// console.log(this.getMaxIndex(this.arr));  
	  
	  
  },
  

  methods: {
	  
	  getItemdata:function(lines,lineindex,oindex)
	  {
		  var tmp="";
		    try {
		    	tmp=lines[lineindex].datas[oindex].name;
			}
			catch(err){
			    
			}
		return tmp
	  },
	  //行合计
	  getRowTotal:function(lines)
	  {
		   var total=0; 
		   lines.forEach(function(lines,idx){
				
					total += lines.datas.length;
				
			});
		   
		   return total
	  },
	  //列合计
	  getColTotal:function(rowlist,colindex)
	  {
		   var total=0; 
		   rowlist.forEach(function(row,idx){
				
					total += row.lines[colindex].datas.length;
				
			});
		   
		   return total
	  },
	  
	  colTotal:function(colindex)
	  {
		   var that=this;
		   var total=0; 
		   this.datalist.forEach(function(data,idx){
				
			   total+=that.getColTotal(data.rowlist,colindex);
				
			});
		   
		   return total
	  },
	  
	  //列合计累计
	  
	  getColTotalSum:function(rowlist,collen)
	  {
		  var total=0; 
		  for(var i=0;i<collen;i++)
		  {
		      total+=this.getColTotal(rowlist, i);
		  }
		 return  total;
		  
	  },
	  
	  
	  colTotalSum:function(collen)
	  {
		   var that=this;
		   var total=0; 
		   this.datalist.forEach(function(data,idx){				
			
			      for(var i=0;i<collen;i++)
				  {
				      total+=that.getColTotal(data.rowlist, i);
				  }
				
			});
		   
		   return total
	  },
	  
	  //返回合并行数 
	  getRowSpan:function(lines)
	  {
		 var arr=lines.map(function(item){			   	
         	 return item.datas.length;
          }); 
		 var maxValue=this.getMax(arr);
		 return Math.ceil(maxValue/this.colnum);
	  },
	  
	  
	  
      //获取最大值
	   getMax:function(arr) {
	      //假设最大值max 为arr[0]
	      var max = arr[0];
	      //遍历对比
	      for (var i = 0; i < arr.length; i++) {
	          //若max小于当前项 说明不是最大值 将当前项的值赋予max 
	          // 继续遍历对比找到最大的值
	          if (max < arr[i]) {
	              max = arr[i];
	          }
	      }
	      return max;
	  }, 
	
	  //获取最大值的下标
	   getMaxIndex: function(arr) {
	      var max = arr[0];
	      //声明了个变量 保存下标值
	      var index = 0;
	      for (var i = 0; i < arr.length; i++) {
	          if (max < arr[i]) {
	              max = arr[i];
	              index = i;
	          }
	      }
	      return index;
	  },
	  
	//获取最小值的下标
	   getMinIndex:function(arr) {
	      var min = arr[0];
	      //声明了个变量 保存下标值
	      var index = 0;
	      for (var i = 0; i < arr.length; i++) {
	          if (min > arr[i]) {
	              min = arr[i];
	              index = i;
	          }
	      }
	      return index;
	  },

	 //获取最小值
	   getMin: function(arr) {
	      var min = arr[0];
	      for (var i = 0; i < arr.length; i++) {
	          if (min > arr[i]) {
	              min = arr[i];
	          }
	      }

	      return min;
	  },
	  
	  
     
	  showError: function(info){		
    	 _alert(info);
      },
  },
  watch:{
     
  }
  
})